<?php


namespace App\Repository\Repositories;


use App\Http\Controllers\Controller;
use App\Models\StoreHeadGoods;
use App\Repository\RepositoryInterface\HeadGoodsInterface;

class HeadGoodsRepositories extends Controller implements HeadGoodsInterface
{
    protected $headGoods;

    public function __construct(StoreHeadGoods $storeHeadGoods)
    {
        $this->headGoods = $storeHeadGoods;
    }

    /**
     * 团长拼团商品添加
     * @param $params
     * @return \Illuminate\Http\JsonResponse
     */
    public function addHeadGoods($params){
        try {
            foreach ($params['cid'] as $v){
                $data = [
                    'cid'=>$v,
                    'hid'=>$params['hid']
                ];
                $res = $this->headGoods::addHeadGoods($data);
            }
            return parent::success("添加商品成功",$res);
        }catch (\Exception $exception){
            return parent::error($exception->getMessage());
        }
    }
}
